from Page_UI.BasePage import BasePage
from selenium.webdriver.common.by import By
class MainPage(BasePage):
    close_the_pop_up_window = (By.XPATH, "//*[text()='close']")
    change_the_language = (By.XPATH, "//*[text()='translate']")
    select_the_language = (By.XPATH, "//*[text()='中文简体']")
    # close_the_pop_up_window = (By.XPATH, "//*[text()='close']")
    click_sign_in = (By.XPATH, "//*[text()='登入']")
    switch_admin_login = (By.XPATH, "//*[contains(text(), '管理员登入')]")
    enter_the_account_number = (By.XPATH, "//input[@aria-label='管理员']")
    enter_your_password = (By.XPATH, "//input[@aria-label='密码']")
    confirm_your_login = (By.XPATH, "//div[@class='q-mx-auto']/../button")
    div_notification_message = (By.XPATH, "//div[contains(@class, 'q-notification__message')]")

    def close_pop_up_window(self):
        self.find_element(self.close_the_pop_up_window).click()

    def one_click_login(self,name_,password_):
        self.find_element(self.click_sign_in).click()
        self.find_element(self.switch_admin_login).click()
        self.find_element(self.enter_the_account_number).send_keys(name_)
        self.find_element(self.enter_your_password).send_keys(password_)
        self.find_element(self.confirm_your_login).click()

    def switch_languages(self):
        self.find_element(self.change_the_language).click()
        self.find_element(self.select_the_language).click()

    def get_notification_message(self, not_null=False):
        return self.find_element(self.div_notification_message).text(not_null)